package com.ztjy.repository.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ztjy.bean.Warehouse;
import com.ztjy.repository.biz.WarehouseBiz;
import com.ztjy.repository.dao.WarehouseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WarehouseBizImpl implements WarehouseBiz {
    @Autowired
    private WarehouseDao wdao;

    @Override
    public PageInfo<Warehouse> findAllRep(Warehouse warehouse, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Warehouse> allRep = wdao.findAllRep(warehouse);
        PageInfo<Warehouse> pageInfo=new PageInfo<Warehouse>(allRep);
        return pageInfo;
    }

    @Override
    public List<Warehouse> findAllWarehouse(Warehouse warehouse) {
        return wdao.findAllRep(warehouse);
    }

    @Override
    public Warehouse findRepById(Integer rid) {
        return wdao.findRepById(rid);
    }

    @Override
    public Boolean addWare(Warehouse warehouse) {
        boolean flag = false;
        try {
            flag = wdao.addWare(warehouse);
        } catch (Exception e) {
            flag = false;
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public Boolean updateWare(Warehouse warehouse) {
        boolean flag = false;
        try {
            flag = wdao.updateWare(warehouse);
        } catch (Exception e) {
            flag = false;
            e.printStackTrace();
        }
        return flag;
    }
}
